//
//  JCMessageNoticeContentView.swift
//  JChat
//
//  Created by JIGUANG on 2017/3/9.
//  Copyright © 2017年 HXHG. All rights reserved.
//

import UIKit
import MTCategory

open class JCMessagePullGiftNotiyContentView: UILabel, JCMessageContentViewType {
    
    public override init(frame: CGRect) {
        super.init(frame: frame)
        _commonInit()
    }
    public required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        _commonInit()
    }

    
    open func apply(_ message: JCMessageType) {
        guard let content = message.content as? JCMessagePullGiftNotiyContent else {
            return
        }
        
        /*
         * targetType -
         * status - 礼物状态
         *
         */
        _extras = content.extras
        /// 礼物消息状态本地缓存
//        if let dict: [String : Any] = message.jmessage?.content?.extras as? [String : Any] {
//            if let partytask: String = dict["messageType"] as? String, partytask == "pullGift" {
//                if let msgId = dict["msgId"] as? String, let status: Int = dict["status"] as? Int {
//                    let giftInfo: MTGiftInfo = MTGiftInfo.create(msgId: msgId, status: MTGiftInfoStatus(rawValue: status)!)
//                    MTGiftInfoDB.shareInstance.insertData(giftInfo)
//                    /// 刷新礼物消息状态
//                    if let index = self.messages.index(message) {
//                        let msg = self._parseMessage(self.conversation.message(withMessageId: message.msgId)!, false)
//                        self.messages[index] = msg
//                        DispatchQueue.main.async {
//                            self.chatView.update(msg, at: index)
//                            MBProgressHUD_JChat.show(text: "礼物领取成功", view: self.view, 1)
//                        }
//                    }
//                }
//            }
//        }
    }
    private var _extras: [String : Any]?
    private func _commonInit() {
    }
}
